layui.use(['table', 'admin', 'ax', 'form', 'formSelects'], function () {
    var $ = layui.$;
    var table = layui.table;
    var $ax = layui.ax;
    var admin = layui.admin;
    var form = layui.form;
    var fs = layui.formSelects;

    /**
     * 档案销毁信息表管理
     */
    var ArchiveInfoReport = {
        tableId: "archiveInfoReportTable"
    };

    /**
     * 初始化表格的列
     */
    ArchiveInfoReport.initColumn = function () {
        return [[
            {field: 'xh', fixed: 'left', width: 120, title: '序号', rowspan: 2},
            {field: 'title', fixed: 'left', width: 200, title: '单位及类型', rowspan: 2},
            {field: 'dac', fixed: 'left', title: '档案数(册)', rowspan: 2},
            {field: 'zlc', fixed: 'left', title: '资料数(份)', rowspan: 2},
            {title: '来源1', colspan: 8, align: 'center'},
            {title: '来源2', colspan: 8, align: 'center'},
            {title: '来源3', colspan: 8, align: 'center'},
        ], [
            {field: 'a5', title: '5年'},
            {field: 'a10', title: '10年'},
            {field: 'a15', title: '15年'},
            {field: 'a20', title: '20年'},
            {field: 'a25', title: '25年'},
            {field: 'a30', title: '30年'},
            {field: 'a35', title: '35年'},
            {field: 'a99', title: '永久'},

            {field: 'b5', title: '5年'},
            {field: 'b10', title: '10年'},
            {field: 'b15', title: '15年'},
            {field: 'b20', title: '20年'},
            {field: 'b25', title: '25年'},
            {field: 'b30', title: '30年'},
            {field: 'b35', title: '35年'},
            {field: 'b99', title: '永久'},

            {field: 'c5', title: '5年'},
            {field: 'c10', title: '10年'},
            {field: 'c15', title: '15年'},
            {field: 'c20', title: '20年'},
            {field: 'c25', title: '25年'},
            {field: 'c30', title: '30年'},
            {field: 'c35', title: '35年'},
            {field: 'c99', title: '永久'},
        ]];
    };

    ArchiveInfoReport.search = function () {
        var condi = $.extend({}, form.val('searchForm'));
        table.reload(ArchiveInfoReport.tableId, {
            where: condi
        });
    };

    //表单提交事件
    form.on('submit(btnSearch)', function (data) {
        ArchiveInfoReport.search();
        return false;
    });


    // 渲染表格
    var tableResult = table.render({
        elem: '#' + ArchiveInfoReport.tableId,
        url: Feng.ctxPath + '/archiveInfoReport/report',
        page: false,
        height: "full-100",
        cellMinWidth: 100,
        cols: ArchiveInfoReport.initColumn()
    });

    // 导出excel
    $('#btnExp').click(function () {
        ArchiveInfoReport.exportExcel();
    });

    /**
     * 导出excel按钮
     */
    ArchiveInfoReport.exportExcel = function () {
        var data = table.cache.archiveInfoReportTable;
        table.exportFile(tableResult.config.id, data, 'xls');

    };

    fs.render('reportType', {
        init: ['0'],
        radio: true,
        on: function (id, vals, val, isAdd, isDisabled) {
            if (isAdd) {

            }
            return true;
        }
    });


});
